<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- CSS -->
<link type="text/css" rel="stylesheet" href="../styles/css/reset.css">
<link type="text/css" rel="stylesheet" href="../styles/css/index.css">
<script type="text/javascript" src="../scripts/html5.js"></script>
<script type="text/javascript" src="../scripts/jquery-1.6.min.js"></script>
<!-- end -->
<title>上传课程附件</title>
<style type="text/css">
.well
{
	background-color: #F5F5F5;
    border: 1px solid #E3E3E3;
    border-radius: 4px 4px 4px 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05) inset;
    margin-bottom: 20px;
    min-height: 20px;
    padding: 19px;
}
</style>
</head>

<script type="text/javascript">
function doDelete(id,courseId){
	if(confirm("您正在删除以上传的课件信息，您确认删除吗？")){
		window.location.href="deleteCourseware.jspx?id="+id+"&courseId="+courseId;
	}
}

function doSubmit(){
	var frm = document.frm;
	if(checkFile()){
		frm.submit();
		/* var formData = $('#frm').serialize();
		$.ajax(function(){
			type:'post',
			data:formDate,
			url:'uploadCourseware.jspx',
			success:function(data){
				alert(data);
			}
		}); */
	}
}

function checkFile(){
	var frm = document.frm;
	var fj = frm.fj.value;
	var exObj = frm.fj;
	var typeRole = ".xls,.xlsx,.pptx,.pdf,.docx,.xls,.doc";
	if(fj=="" || fj==null){
		alert("请选择导入的excel文件！");
		return false;
	}else{
		var fj_temp = fj.substr(fj.lastIndexOf(".")).toLowerCase();
		if(typeRole.indexOf(fj_temp)==-1){
			alert("请选择.xls,.xlsx,.pptx,.pdf,.docx,.xls,.doc或.xlsx格式的文档！");
			return false;
		}
	}

	return true;
}	
</script>

<body>
	<c:if test="${! empty message }">
		<script type="text/javascript" language="javascript">
		 window.onload =function(){
			 var message = "${message}";
			 alert(message);
		 }
		</script>
	</c:if>
<header>
	<div class="headerWrap"></div>
	</header>

 <div class="content">

		<section>
	<div class="rc_info mt20">
		<h3>
			<span class="r_title_ico"></span>课程相关信息
		</h3>
    </div>
    <table class="rc_tab01" cellspacing="0" cellpadding="0">
    	<tbody>
    		<tr>
    			<th style="text-align: center;width: 20%">课程名</th>
    			<th style="text-align: center;width: 20%">授课教师</th>
    			<th style="text-align: center;width: 25%">上课时间</th>
    			<th style="text-align: center;">上课地点</th>
    		</tr>
    		<tr>
    			<td style="text-align: center;">${courseDto.name }</td>
    			<td style="text-align: center;">${courseDto.teacherName }</td>
    			<td style="text-align: center;"><fmt:formatDate
								value="${courseDto.teachTime }" pattern="yyyy年MM月dd日HH点mm分" /></td>
				<td style="text-align: center;">${courseDto.classroom }</td>
    		</tr>
    	</tbody>
    </table>
		<br>
   <div class="rc_info mt20">
			<h3>
				<span class="r_title_ico"></span> 课程附件导入
			</h3>
		</div>
  <form action="uploadCourseware.jspx" enctype="multipart/form-data" method="post" name="frm" id="frm" >
  <div class="rc_fbt">
				<p class="left">
	<input type="hidden" name= "courseId" value="${courseId }">			
   <input type="file" name="fj"  size="50"/>
                </p>
                
                <p class="left">
  <a href="#" class="btn2 mt7 ml10 left" onclick="doSubmit();"><span>上传</span></a>
                </p>
  
  </div>
  </form>
  <br>
  <c:if test="${coursewareDtos.size() >0 }">
  	<div class="rc_info mt20">
		<h3>
			<span class="r_title_ico"></span>课程附件信息
		</h3>
    </div>
    
  	<table class="rc_tab01" cellspacing="0" cellpadding="0">
  		<tr>
  			<th style="text-align: center;">附件名称</th>
  			<th style="text-align: center;">附件大小</th>
  			<th style="text-align: center;">操作</th>
  		</tr>
  	<c:forEach items="${coursewareDtos }" var="coursewareDto" varStatus="s">
  		<tr>
  		
  		<td style="text-align: center;">${coursewareDto.wareName }</td>
  		<td style="text-align: center;">未知</td>
  		<td style="text-align: center;"><a onclick="doDelete('${coursewareDto.id}','${courseId}');">删除</a></td>
  		
  		</tr>
  	
  	</c:forEach>
  	</table>
  	
  </c:if>
  <br>
  <div class="well">
  	<h3 style="text-align: left;font-size: 20px;line-height: 35px">上传须知</h3>
  	<ul>
       <li style="font-size: 14px;line-height: 20px">目前系统允许上传的格式为 (<strong>.xls,.xlsx,.pptx,.pdf,.docx,.xls,.doc</strong>)。</li>
       <li style="font-size: 14px;line-height: 20px">允许上传的文件数量为：<strong>3</strong>。</li>
    </ul>
  
  </div>
  
  </section>
 </div> 
  
<%@include file="/common/foot.jsp"%>